<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="assets/images/favicon.ico" rel="icon">
    <title>宿迁南钢金鑫</title>
    <link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="assets/module/admin.css?v=317"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        let userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
        if ((userAgent.indexOf("Firefox") == -1) && (userAgent.indexOf("Chrome") == -1)) {
            alert("您的浏览器可能存在兼容问题，推荐您使用：火狐浏览器，若您使用360浏览器请将浏览器切换到极速模式");
        }
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部 -->
    <div class="layui-header">
        <div class="layui-logo">
            <img src="assets/images/logo.png"/>
            <cite>&nbsp;宿迁金鑫</cite>
        </div>
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="message" title="消息">
                    <i class="layui-icon layui-icon-notice"></i>
                    <span id="badge-dot"></span>
                </a>
            </li>
            <!--<li class="layui-nav-item" lay-unselect>-->
                <!--<a ew-event="note" title="便签"><i class="layui-icon layui-icon-note"></i></a>-->
            <!--</li>-->
            <!--<li class="layui-nav-item layui-hide-xs" lay-unselect>-->
                <!--<a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a>-->
            <!--</li>-->
            <li class="layui-nav-item" lay-unselect>
                <a>
                    <img src="assets/images/head.jpg" class="layui-nav-img">
                    <span id="truName"> </span>
                </a>
                <dl class="layui-nav-child">
                    <!--<dd lay-unselect><a ew-href="/template/user-info.html">个人中心</a></dd>-->
                    <!--<dd lay-unselect><a ew-event="psw">修改密码</a></dd>-->
                    <!--<hr>-->
                    <dd lay-unselect><a ew-event="logout" data-url="login.html">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>
            </li>
        </ul>
    </div>

    <!-- 侧边栏 -->
    <div class="layui-side">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="all">
            </ul>
        </div>
    </div>

    <!-- 主体部分 -->
    <div class="layui-body"></div>
    <!-- 底部 -->
    <div class="layui-footer layui-text">
        copyright © 2020 <a href="http://easyweb.vip" target="_blank">宿迁金鑫</a> all rights reserved.
        <span class="pull-right">version 1.1.0</span>
    </div>
</div>

<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="./assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="./assets/js/common.js?v=317"></script>
<script src="assets/js/jquery-3.2.1.min.js"></script>
<script src="assets/js/js.cookie.min.js"></script>
<script src="assets/js/sqjx.js"></script>
<script>
    layui.use(['index', 'form'], function () {
        var index = layui.index;
        var account = getUrlParam();
        if (account) {
            $.post('/office/user/login', {userName: account, password: 'sqjx'}, function (res) {
                if (res.code == 200) {
                    localStorage.setItem("userId", res.obj.userId);
                    localStorage.setItem("userName", res.obj.trueName);
                    localStorage.setItem("orgName", res.obj.roles);
                    localStorage.setItem("account", res.obj.account);
                    document.cookie = "token" + "=" + res.obj.token;
                    loadMenu();
                    index.loadHome({
                        menuPath: 'page/flow/approve.html',
                        menuName: '<i class="layui-icon layui-icon-home">我的任务</i>'
                    });
                    setInterval(queryTaskList, 50000);
                } else {
                   showAlert(res.msg);

                   return
                }
            })
        } else {
            loadMenu();
            index.loadHome({
                menuPath: 'page/flow/approve.html',
                menuName: '<i class="layui-icon layui-icon-home">我的任务</i>'
            });
            setInterval(queryTaskList, 50000);
        }

    });

    function queryTaskList() {
        if(env=="dev"){
            return
        }
        $.post('/office/flowStepApprove/queryTaskList', {page: 1, rows: 15, status: 2}, function (res) {
            if (res.code == 200) {
                if (res.obj.rows.length != 0) {
                    $("#badge-dot").addClass('layui-badge-dot')
                } else {
                    $("#badge-dot").removeClass('layui-badge-dot')
                }
            }
        });
    }

    function loadMenu() {
        $.post('/office/menu/loadMenu', function (res) {
            if (res.code == 200) {
                var tree = res.obj[0];
                var menuLi = "";
                tree.children.forEach(item => {
                    let li = `<li class="layui-nav-item">`;
                    let a = ` <a><i class="layui-icon ${item.iconCls}"></i>&emsp;<cite>${item.text}</cite></a>`;//一级菜单
                    if (item.children) {
                        //菜单下的模块
                        let dl = `<dl class="layui-nav-child">`;
                        item.children.forEach(each => {
                            let dd = `<dd><a lay-href="page${each.url}">${each.text}</a></dd>`;
                            if (each.url.indexOf("http://") != -1) {
                                //外部请求单独处理
                                dd = `<dd><a lay-href="${each.url}">${each.text}</a></dd>`;
                            }
                            dl += dd
                        })
                        dl += "</dl>";
                        a = a + dl + "</a>"
                    }
                    li += a + "</li>";
                    menuLi += li;
                });
                $(".layui-nav-tree").html(menuLi);
                layui.use('element', function () {
                    var element = layui.element;
                    element.init();
                });
            }
            queryTaskList();
            $("#truName").text(getUserName());
        })
    }
</script>
</body>
</html>
